import { Scene } from "../../../../../Core/Module/Entity/Scene";
import { SceneType } from "../../../../../Core/Module/Entity/SceneType";
import { ActorMessageHandlerAttribute } from "../../../../../Decorator/Decorator";
import { ETTask } from "../../../../../Support/Share/Lib/Async/ETTask";
import { ObjectUnLockRequest, ObjectUnLockResponse } from "../../../../Model/Generate/Share/Message/InnerMessage_S_20001";
import { LocationComponent } from "../../../../Model/Server/Module/ActorLocation/LocationComponent";
import { AMActorRpcHandler } from "../Actor/AMActorRpcHandler";

@ActorMessageHandlerAttribute(SceneType.Location, ObjectUnLockRequest, ObjectUnLockResponse)
export class ObjectUnLockRequestHandler extends AMActorRpcHandler<Scene, ObjectUnLockRequest, ObjectUnLockResponse> {

    protected override async Run(scene: Scene, request: ObjectUnLockRequest, response: ObjectUnLockResponse): Promise<void> {
        scene.GetComponent<LocationComponent>(LocationComponent).UnLock(request.Key, request.OldInstanceId, request.InstanceId);

        await ETTask.CompletedTask;
    }

}